<?php
	class youhui extends spModel
	{
		var $pk = 'pid';
		var $table = "youhui"; // 数据表的名称

		var	$verifier = array(
			"rules" => array(
				'title' => array(  
	                'notnull' => TRUE, 
	                'minlength' => 3,  
				),
				'startdate' => array(
					'notnull' => TRUE, 
				),
				'enddate' => array(
					'notnull' => TRUE, 
				),
				'catid' => array(
					'notnull' => TRUE,
				),
				'url' => array(
					'notnull' => TRUE, 
				),
			),
		);

		var $linker = array(  
			array(  
			   'type' => 'hasone',   // 关联类型，这里是一对一关联  
			   'map' => 'store_detail',    // 关联的标识  
			   'mapkey' => 'store_id', // 本表与对应表关联的字段名  
			   'fclass' => 'm_store', // 对应表的类名  
			   'fkey' => 'store_id',    // 对应表中关联的字段名  
			   'enabled' => true     // 启用关联  
			)
		);


		function findCat($arr_cat = array())
		{
			foreach($arr_cat as $k=>$v)
			{
				//$condition = array('catid'=>$k, 'status'=>0, 'isdel'=>0);
				$condition = " catid='$k' AND status=0 AND isdel=0 AND enddate>=curdate()";
				$result = $this->findCount($condition);
				if($result == 0) continue;
				$arr_cat_num[$k] = array('catid'=>$k, 'title'=>$v, 'nums'=>$result);
			}
			return $arr_cat_num;
		}
	}
?>